package org.mydzms.com.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.dzms.services.foodClassService;


/**
 * Servlet implementation class FoodSerchServlet
 */
public class FoodSerchServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		String a = request.getParameter("serch");
		System.out.println(a);
		String b="%"+a+"%";
		String cp = request.getParameter("cp")==null?"1":request.getParameter("cp");
		String cond = request.getParameter("cond")==null?" ":request.getParameter("cond");
		foodClassService fc = new foodClassService();
		HttpSession session = request.getSession();
		session.setAttribute("food", fc.findPage2(b, Integer.parseInt(cp), cond));
		request.getRequestDispatcher("foodClass.jsp").forward(request, response);
//		request.setSession("food",fc.findPage2(b, Integer.parseInt(cp), cond));
		
		
	}

}
